package test.utils.depre.sakis;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import java.util.ArrayList;

import static com.badlogic.gdx.Gdx.graphics;

abstract public class AbstractAnimation {
    public ArrayList<Texture> textures = new ArrayList<>();
    public float timeElapsed;
    public float interval;
    public int standbyIndex;
    public int currentImageIndex;
    public int totalImages;
    public boolean isPlayingAnimation;
    public Texture currentImage;

    public AbstractAnimation(ArrayList<Texture> textures, float timeElapsed, float interval,int standbyIndex) {
        this.textures = textures;
        this.timeElapsed = timeElapsed;
        this.interval = interval;
        this.standbyIndex = standbyIndex;
        this.currentImageIndex = 0;
        this.totalImages = textures.size();
        this.isPlayingAnimation = false;
    }

    public AbstractAnimation(ArrayList<Texture> textures) {
        this(textures, 0f, 0.05f,0);
    }

    public void render(SpriteBatch sb) {

    }

    public void update() {
        timeElapsed += graphics.getDeltaTime();

        if (timeElapsed >= interval) {
            timeElapsed = 0f;
            currentImageIndex++;

            if (currentImageIndex >= totalImages) {
                currentImageIndex = 0;
            }

            currentImage = textures.get(currentImageIndex);
        }
    }

}
